home *** CD-ROM | disk | FTP | other *** search
/ isnet Internet / Isnet Internet CD.iso / prog / hiz / 09 / 09.exe / adynware.exe / perl / lib / assert.pl < prev    next >
Encoding:
Text File  |  1999-12-28  |  878 b   |  43 lines

  1.  
  2. sub assert {
  3.     &panic("ASSERTION BOTCHED: $_[$[]",$@) unless eval $_[$[];
  4.  
  5. sub panic {
  6.     package DB;
  7.  
  8.     select(STDERR);
  9.  
  10.     print "\npanic: @_\n";
  11.  
  12.     exit 1 if $] <= 4.003;  # caller broken
  13.  
  14.  
  15.     local $_;
  16.     my $i;
  17.     my ($p,$f,$l,$s,$h,$a,@a,@frames);
  18.     for ($i = 0; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
  19.     @a = @args;
  20.     for (@a) {
  21.         if (/^StB\000/ && length($_) == length($_main{'_main'})) {
  22.         $_ = sprintf("%s",$_);
  23.         }
  24.         else {
  25.         s/'/\\'/g;
  26.         s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
  27.         s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
  28.         s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
  29.         }
  30.     }
  31.     $w = $w ? '@ = ' : '$ = ';
  32.     $a = $h ? '(' . join(', ', @a) . ')' : '';
  33.     push(@frames, "$w&$s$a from file $f line $l\n");
  34.     }
  35.     for ($i=0; $i <= $#frames; $i++) {
  36.     print $frames[$i];
  37.     }
  38.     exit 1;
  39.  
  40. 1;
  41.